package cinema.Dao;

import javax.ejb.Stateless;
import javax.persistence.NoResultException;

import cinema.Entity.Room;
import cinema.Entity.Row;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("serial")
@Stateless
public class RowDAO extends AbstractDAO<Row>{

	public RowDAO() {
		super(Row.class);
	}

    public List<Row> findRowsForRoom(Room room){
        try{
            return em.createQuery("select r from Row r where r.room = :room", Row.class)
                    .setParameter("room", room)
                    .getResultList();
        }
        catch(NoResultException e){
            return new ArrayList<Row>();
        }
    }
	
}